home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 187_01 / mkstr.c < prev    next >
C/C++ Source or Header  |  1985-12-29  |  1KB  |  36 lines

  1. /*@*****************************************************/
  2. /*@                                                    */
  3. /*@ mkstr - copy the input to the output ensuring      */
  4. /*@        the result is zero-terminated.  End of      */
  5. /*@        string on input is CR, LF, EOS, ';', ' ',   */
  6. /*@        or the max number of chars is copied.       */
  7. /*@                                                    */
  8. /*@   Usage:     mkstr(max, in, out);                  */
  9. /*@       where max is the max no. of char that out    */
  10. /*@                  can accept.                       */
  11. /*@             in is a pointer to the input area.     */
  12. /*@             out is a pointer to the output area.   */
  13. /*@                                                    */
  14. /*@*****************************************************/
  15.  
  16. #define CR  0x0D
  17.  
  18. mkstr(maxlen, istr, ostr)
  19. int maxlen;
  20. char *istr;
  21. char *ostr;
  22. {
  23.     char c;
  24.  
  25.     while ((--maxlen) > 0) {
  26.         c = *ostr++ = *istr++;
  27.         if ((*ostr == '\n') || (*ostr == ';') ||
  28.              (*ostr == ' ') || (*ostr == CR)) {
  29.             ostr--;
  30.             break;
  31.         }
  32.     }
  33.     *ostr = '\0';
  34. }
  35.  
  36.